/*
 * DConfirmacion.java
 *
 * Created on 30 de agosto de 2006, 02:22 PM
 */

package ig.formato.gui.app;

/**
 *
 * @author  jsanchez
 */
public class DConfirmacion extends javax.swing.JDialog {
    private Integer presButton=null;
    /** Creates new form DConfirmacion */
    public DConfirmacion(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setTitle("Mensaje");
        this.setSize(this.getWidth(),210);
        this.setResizable(true);
        this.centrar();
    }
    public void centrar() {
        java.awt.Dimension dimensionScreen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Rectangle dimensionPantalla = getBounds();
        setLocation((dimensionScreen.width - dimensionPantalla.width) / 2, (dimensionScreen.height - dimensionPantalla.height) / 2);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        Aceptar = new javax.swing.JButton();
        Cancelar = new javax.swing.JButton();
        c_detalle = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        Mensaje = new javax.swing.JTextPane();
        jScrollPane4 = new javax.swing.JScrollPane();
        Solucion = new javax.swing.JTextPane();
        SDetalle = new javax.swing.JScrollPane();
        detalle = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.Form.title")); // NOI18N
        setModal(true);
        setResizable(false);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ig/formato/util/images/igformato.gif"))); // NOI18N
        jLabel1.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.jLabel1.text")); // NOI18N

        Aceptar.setFont(new java.awt.Font("Dialog", 1, 10));
        Aceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ig/formato/util/images/ok.png"))); // NOI18N
        Aceptar.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.Aceptar.text")); // NOI18N
        Aceptar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        Aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AceptarActionPerformed(evt);
            }
        });

        Cancelar.setFont(new java.awt.Font("Dialog", 1, 10));
        Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ig/formato/util/images/cancel.png"))); // NOI18N
        Cancelar.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.Cancelar.text")); // NOI18N
        Cancelar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelarActionPerformed(evt);
            }
        });

        c_detalle.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
        c_detalle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        c_detalle.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.c_detalle.text")); // NOI18N
        c_detalle.setToolTipText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.c_detalle.toolTipText")); // NOI18N
        c_detalle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        c_detalle.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                c_detalleMouseReleased(evt);
            }
        });

        jScrollPane3.setBorder(null);

        Mensaje.setBorder(null);
        Mensaje.setEditable(false);
        Mensaje.setFont(new java.awt.Font("Dialog", 1, 12));
        Mensaje.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.Mensaje.text")); // NOI18N
        Mensaje.setOpaque(false);
        jScrollPane3.setViewportView(Mensaje);

        jScrollPane4.setBorder(null);

        Solucion.setBorder(null);
        Solucion.setEditable(false);
        Solucion.setText(org.openide.util.NbBundle.getMessage(DConfirmacion.class, "DConfirmacion.Solucion.text")); // NOI18N
        Solucion.setOpaque(false);
        jScrollPane4.setViewportView(Solucion);

        detalle.setColumns(20);
        detalle.setRows(5);
        SDetalle.setViewportView(detalle);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, SDetalle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(Aceptar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(Cancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 81, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(c_detalle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE))
                            .add(layout.createSequentialGroup()
                                .add(9, 9, 9)
                                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 82, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(layout.createSequentialGroup()
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 50, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(c_detalle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(SDetalle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(Cancelar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(Aceptar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void c_detalleMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_c_detalleMouseReleased
        if(SDetalle.isVisible()){
            SDetalle.setVisible(false);
            this.setLocation(getX(), getY()+70);
            this.setSize(this.getWidth(),210);
        }else {
            this.setLocation(getX(), getY()-70);
            SDetalle.setVisible(true);
            this.setSize(this.getWidth(),500);
        }
        this.repaint();
        this.detalle.updateUI();
    }//GEN-LAST:event_c_detalleMouseReleased
    
    private void CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelarActionPerformed
        this.presButton=0;
        this.dispose();
    }//GEN-LAST:event_CancelarActionPerformed
    
    private void AceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AceptarActionPerformed
        this.presButton=1;
        this.dispose();
    }//GEN-LAST:event_AceptarActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static Integer show(java.awt.Frame parent,ig.formato.util.IGFormatoException e) {
        DConfirmacion d=new DConfirmacion(parent,true);
        d.Mensaje.setText(e.getMensaje());
        d.Solucion.setText(e.getSolucion());
        d.detalle.setText(e.getPrintStackTrace());
        d.SDetalle.setVisible(false);
        d.setVisible(true);
        return d.presButton;
    }
    
    public static Integer show(java.awt.Frame parent,String mensaje) {
        DConfirmacion d=new DConfirmacion(parent,true);
        d.Mensaje.setText(mensaje);
        d.c_detalle.setVisible(false);
        d.Solucion.setVisible(false);
        d.SDetalle.setVisible(false);
        d.setVisible(true);
        return d.presButton;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Aceptar;
    private javax.swing.JButton Cancelar;
    private javax.swing.JTextPane Mensaje;
    private javax.swing.JScrollPane SDetalle;
    private javax.swing.JTextPane Solucion;
    private javax.swing.JLabel c_detalle;
    private javax.swing.JTextArea detalle;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    // End of variables declaration//GEN-END:variables
    
}
